from starlette.requests import Request

from fastadmin import template


async def locale_processor(request: Request, call_next):
    locale = request.headers.get("Accept-Language")
    template.set_locale(locale)
    response = await call_next(request)
    return response
